package com.ailanyin.common.security.constants;

import java.util.Arrays;
import java.util.List;

/**
 * @author ailanyin
 * @version 1.0
 * @since 2022/9/8 0008 下午 14:54
 */
public class SecurityConstant {

    public static final int MAX_ERROR_COUNT = 5;
    public static final String HAS_BEEN_PULLED_BLACK = "您的IP已经被系统拉黑";
    public static final String BLACKLIST_KEY = "login:blacklist";
    public static final String LOGIN_ERROR_COUNT = "login:errorCount:";
    public static final String BLACKLIST_ON = "true";
    public static final String BLACKLIST_ON_OFF_KEY = "sys_config:sys.account.blacklistOnOff";
    public static final String CAPTCHA_KEY = "login:captcha:";
    public static final String CAPTCHA_ON_OFF_KEY = "sys_config:sys.account.captchaOnOff";
    public static final String CAPTCHA_ON = "true";
    public static final String REGISTER_ON_OFF_KEY = "sys_config:sys.account.registerUser";
    public static final String REGISTER_ON = "true";
    public static final String REDIS_SECRET_KEY = "sys:secret:secret";
    /**
     * 登录成功
     */
    public static final String LOGIN_SUCCESS = "登录成功";
    /**
     * 登录失败
     */
    public static final String LOGIN_FAIL = "登录失败";
    /**
     * 账号或密码错误
     */
    public static final String USERNAME_OR_PASSWORD_ERROR = "账号或密码错误";

    /**
     * token header
     */
    public static final String TOKEN_HEADER = "Authorization";

    /**
     * token前缀
     */
    public static final String TOKEN_HEAD = "Bearer ";

    /**
     * 鉴权白名单
     */
    public final static List<String> SECURITY_WHITELIST = Arrays.asList(
            "/" ,
            "/*.*" ,
            "/favicon.ico" ,
            "/**/*.html" ,
            "/**/*.css" ,
            "/**/*.js" ,
            "/swagger-resources/**" ,
            "/v2/api-docs/**" ,
            "/druid/**" ,
            "/file/**" ,
            "/es/**" ,
            "/websocket/**" ,
            "/search/ikdict/get" ,
            "/login" ,
            "/register" ,
            "/captchaImage"
    );

    /**
     * Xss过滤白名单
     */
    public final static List<String> XSS_WHITELIST = Arrays.asList(
            "/captchaImage" ,
            "/login",
            "/workflow/process/start",
            "/workflow/model/save"
    );

    /**
     * 需要限流的接口
     */
    public final static List<String> LIMIT_URI = Arrays.asList(
            "/captchaImage" ,
            "/login" ,
            "/register"
    );

    /**
     * 限流的RedisKey
     */
    public final static String RATE_LIMIT_KEY = "rateLimit:";

    /**
     * 同IP每秒最大允许访问次数
     */
    public final static Integer MAX_RATE_LIMIT_TOTAL = 5;
}
